/**
 * Write a description of class TJU_1922A here.
 * 
 * @author Josh Lear
 * @version 6/14/2014
 * Flood fill, Dynamic Programming
 */
import java.util.Scanner;
public class TJU_1922
{
   public static char[][] mat;
   public static boolean[][] visited;
   public static boolean[][] empty;
   public static int counter;
   public static int h;
   public static int w;
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       while(true){
           counter = 0;
            h = sc.nextInt();
            w = sc.nextInt();
           int r = sc.nextInt()-1;
           int c = sc.nextInt()-1;
           if(h == 0){break;}
           mat = new char[h][w];
           visited = new boolean[h][w];
           empty = new boolean[h][w];
           for(int i = 0; i < h; i++){
               String cur = sc.next();
               for(int j = 0; j < w; j++){
                   mat[i][j] = cur.charAt(j);
                }
            }
           fill(r, c);
           System.out.println(counter);
        }
    }
    //return true if this spot is empty, false if it is filled
   public static boolean fill(int r, int c){
     
       if(!inBounds(r, c)){
           return true;
        }
       //if we've been here before, return
       if(visited[r][c] && empty[r][c]){return true;}
       if(visited[r][c] && !empty[r][c]){return false;}
       visited[r][c] = true;
       if(mat[r][c] == 'X'){
           int[] x = {1, -1, 0, 0, 1, -1, 1, -1};
           int[] y = {0, 0, 1, -1, 1, -1, -1, 1};
                    for(int i = 0; i < 4; i++){
           if(fill(r+y[i], c+x[i])){
               counter++;
            }
        }
            for(int i = 4; i < 8; i++){
           fill(r+y[i], c+x[i]);
        }
        empty[r][c] = false;
        return false;
        }
       empty[r][c] = true;
       
        return true;
    }
   public static boolean inBounds(int r, int c){
       return (h > r && r >= 0 && w > c && c >= 0); 
    }
}